import java.util.Random;
import java.util.Scanner;

public class demo_Scanner {
    public static void main(String[] args) {
        /* 输入一个值并打印出来 */
//        scanner();

//        scanner_max();
//        getRandom();
        guessNum();
    }

    /* 输入一个文本 */
    public static void scanner() {
        System.out.print("输出了1");
        Scanner scanner = new Scanner(System.in);
        String str = scanner.next();
        System.out.print("输入的值是：" + str);
    }

    /* 求输入的两个int型数字的和 */
    public static void scanner_sum() {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        System.out.print("和为 " + (a + b));
    }

    /* 求出输入的三个数的最大值 */
    public static void scanner_max() {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = scanner.nextInt();

        int max = a;

        if (b > max) {
            max = b;
        }
        if (c > max) {
            max = c;
        }

        System.out.print("最大值是" + max);
    }

    /* 生成一个随机数 */
    public static void getRandom() {
        Random r = new Random();
        /* 左闭右开 */
        System.out.print(r.nextInt(10));
    }

    /* 猜数字 */
    public static void guessNum() {
        /* 要生成一个1-100的随机数 */
        int randomNum = new Random().nextInt(100) + 1;
        System.out.println("游戏开始，请输入一个1-100的数字，看看你是否能猜中");
        /* 要输入一个数字 */
        Scanner scanner = new Scanner(System.in);

        while (true) {
            int guessNum = scanner.nextInt();
            if (randomNum > guessNum) {
                System.out.println("太小了,请重试");
            } else if (randomNum < guessNum) {
                System.out.println("太大了，请重试");
            } else {
                System.out.println("恭喜你猜对了，游戏结束");
                break;
            }
        }
        System.out.println("游戏结束");


    }
}
